# Ofri Keidar Inbal Wiesel 302933981 305331878

'''
Class manages writing all outputs to results file
'''
class OutputMngr:
    
    '''
    Constructor- creates object to manage writing the outputs 
    '''
    def __init__(self, outputFileName):
    
        # initialize counter for printed lines
        self.lineCtr = 1;
    
        # create output file
        self.outputFile = open(outputFileName, "w");
    
    '''
    Writes given students names and ID numbers to output file
    '''
    def writePersonalDetails(self, names, ids):
        
        # compose data string
        data = "#Students\t" + names[0] + "\t" + names[1] + "\t" + ids[0] + "\t" + ids[1];
        
        # write output as a new line
        self.outputFile.write(data + "\n");
     
    '''
    Writes given string to the output file as a new line
    '''
    def writeLine(self, newLine):
        
        # write output as a new line
        data = "#Output" + str(self.lineCtr) + "\t" + str(newLine);
        self.outputFile.write(data + "\n");
        
        # increment line counter
        self.lineCtr += 1;
    
    '''
    Writes a new line to a table: columns are given values separated by tabs.
    Does not add a serial number (#Output)
    '''
    def writeTableEntry(self, firstParam, secondParam, thirdParam, fourthParam):
        
        # write output as a new line
        data = str(firstParam) + "\t" + str(secondParam) + "\t" + str(thirdParam) + "\t" + str(fourthParam);
        self.outputFile.write(data + "\n");
    
    '''
    Closes output file
    '''
    def closeOutput(self):
        self.outputFile.close()
